package com.shop.cereshop.commons.tencent.moderation.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @description: 腾讯云内容审核配置类
 * @author zdd
 * @date 2025/10/26 14:13
 * @version 1.0
 */
@Data
@Component
@ConfigurationProperties(prefix = "tencent.moderation")
public class TencentModerationConfig {

    private String secretId;
    private String secretKey;
    private String region = "ap-guangzhou";

    private ModerationConfig moderation = new ModerationConfig();

    @Data
    public static class ModerationConfig {
        private TextConfig text = new TextConfig();
        private ImageConfig image = new ImageConfig();
        private VideoConfig video = new VideoConfig();
        private CacheConfig cache = new CacheConfig();
        private RetryConfig retry = new RetryConfig();
    }

    @Data
    public static class TextConfig {
        private String bizType = "text_biz";
        private boolean enabled = true;
        private int timeout = 5000;
        private int maxLength = 10000;
    }

    @Data
    public static class ImageConfig {
        private String bizType = "image_biz";
        private boolean enabled = true;
        private int timeout = 10000;
        private long maxFileSize = 10485760L; // 10MB
        private String[] supportedFormats = {"jpg", "jpeg", "png", "gif", "bmp"};
    }

    @Data
    public static class VideoConfig {
        private String bizType = "video_biz";
        private boolean enabled = true;
        private int pollingInterval = 30000;
        private int maxPollingTimes = 60;
        private int timeout = 30000;
        private String[] supportedFormats = {"flv", "mkv" , "mp4" , "rmvb" , "avi" , "wmv", "3gp", "ts", "mov", "rm", "mpeg", "wmf"};
        private String callbackUrl = "http://61.184.3.185:9007/tencent/moderation/video/callback";
    }

    @Data
    public static class CacheConfig {
        private boolean enabled = true;
        private String type = "redis"; // local 或 redis
        private int size = 10000;
        private int ttl = -1; // 不过期
        private LocalCacheConfig local = new LocalCacheConfig();
    }

    @Data
    public static class LocalCacheConfig {
        private int size = 1000;
        private int ttl = 300; // 5分钟
    }

    @Data
    public static class RetryConfig {
        private int maxAttempts = 3;
        private long delay = 1000;
        private double multiplier = 2.0;
    }

}
